Skip to content

internal: (studio) set up hot reloading for the studio bundle #31796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
May 30, 2025

Conversation

ryanthemanuel
Copy link
Collaborator

@ryanthemanuel ryanthemanuel commented May 28, 2025

Additional details

This PR sets up hot reloading for the cloud delivered studio code when CYPRESS_STUDIO_LOCAL_PATH is set. When that environment variable is set, we set up a watcher for the server file and trigger the studio life cycle manager loading promise when that file changes. This promise will eventually resolve with the new studio code and notify the appropriate listeners of the update (note that we don't clean up the listeners when the environment variable is set). Some additional code streamlining has also been done to make this watching a little bit easier to implement.

Steps to test

How has the user experience changed?

PR Tasks

Copy link

cypress bot commented May 28, 2025

cypress    Run #62753

Run Properties:  status check passed Passed #62753  •  git commit 7b14bf8fe1: PR comments
Project cypress
Branch Review ryanm/internal/hot-reloading
Run status status check passed Passed #62753
Run duration 18m 59s
Commit git commit 7b14bf8fe1: PR comments
Committer Ryan Manuel
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 13
Tests that did not run due to a developer annotating a test with .skip  Pending 1232
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 32181
View all changes introduced in this branch ↗︎
UI Coverage  45.83%
  Untested elements 190  
  Tested elements 165  
Accessibility  92.74%
  Failed rules  3 critical   9 serious   2 moderate   2 minor
  Failed elements 697  

@ryanthemanuel ryanthemanuel self-assigned this May 29, 2025
@ryanthemanuel ryanthemanuel requested a review from Copilot May 29, 2025 03:08
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the studio bundle loading and enables hot reloading of the local studio bundle by:

  • Introducing ensureStudioBundle and getCloudMetadata helpers and updating the StudioLifecycleManager to use them.
  • Updating tooling snapshots, scripts, and the pack hook to reference the new studio files.
  • Adding file‐watching logic in Gulp tasks and the lifecycle manager for local‐path‐based development.

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tooling/v8-snapshot/cache/linux/snapshot-meta.json Replaced old studio manager snapshot entries with new studio files
tooling/v8-snapshot/cache/darwin/snapshot-meta.json Same updates for Darwin snapshots
scripts/gulp/tasks/gulpCloudDeliveredTypes.ts Switched to ensureStudioBundle and added chokidar watchers
scripts/after-pack-hook.js Updated paths and validations for new studio files
packages/server/lib/cloud/studio/ensure_studio_bundle.ts New helper for downloading and extracting the studio bundle
packages/server/lib/cloud/studio/StudioLifecycleManager.ts Refactored to use new helpers, add caching, and hot-reload logic
packages/server/lib/cloud/get_cloud_metadata.ts New utility to fetch cloud URL and headers
packages/server/lib/project-base.ts Switched to getCloudMetadata for unified cloud config
Various test files in packages/server/test/unit/cloud/studio Adjusted imports and added tests for new modules

Copy link
Contributor

@astone123 astone123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing hot updates for server code, for instance in spec-writer.ts, but I do see them for code in the app folder. Is this expected, or is there something up with my environment maybe

@ryanthemanuel
Copy link
Collaborator Author

I'm not seeing hot updates for server code, for instance in spec-writer.ts, but I do see them for code in the app folder. Is this expected, or is there something up with my environment maybe

We worked through this offline. There were some issues on @astone123's machine with watching files in general.

@ryanthemanuel ryanthemanuel requested a review from mschile May 30, 2025 02:18
StudioLifecycleManager.watcher = chokidar.watch(path.join(process.env.CYPRESS_LOCAL_STUDIO_PATH, 'server', 'index.js'), {
awaitWriteFinish: true,
}).on('change', async () => {
await this.studioManager?.destroy()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a console.log here so we have an indicator that the server has reloaded.

@ryanthemanuel ryanthemanuel merged commit fed81d4 into develop May 30, 2025
89 of 91 checks passed
@ryanthemanuel ryanthemanuel deleted the ryanm/internal/hot-reloading branch May 30, 2025 18:38
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 3, 2025

Released in 14.4.1.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v14.4.1, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants